
package com.jeedcp.quartz.controller;


import com.jeedcp.core.annotation.LogOperationAno;
import com.jeedcp.core.common.JsonResult;
import com.jeedcp.core.controller.BaseController;
import com.jeedcp.quartz.dto.ScheduleJobDTO;
import com.jeedcp.quartz.entity.ScheduleJobEntity;
import com.jeedcp.quartz.service.ScheduleJobService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

/**
 * 定时任务
 */
@RestController
@RequestMapping("/sys/schedule")
@Api(tags="定时任务")
public class ScheduleJobController  extends BaseController<ScheduleJobService, ScheduleJobEntity, ScheduleJobDTO> {

	@PutMapping("/run")
	@ApiOperation("立即执行")
	@LogOperationAno("立即执行")
//	@RequiresPermissions("sys:schedule:run")
	public JsonResult run(@RequestBody String[] ids){
		baseService.run(ids);
		return new JsonResult().success("立即执行任务成功");
	}

	@PutMapping("/pause")
	@ApiOperation("暂停")
	@LogOperationAno("暂停")
//	@RequiresPermissions("sys:schedule:pause")
	public JsonResult pause(@RequestBody String[] ids){
		baseService.pause(ids);
		
		return new JsonResult().success("暂停任务成功");
	}

	@PutMapping("/resume")
	@ApiOperation("恢复")
	@LogOperationAno("恢复")
//	@RequiresPermissions("sys:schedule:resume")
	public JsonResult resume(@RequestBody String[] ids){
		baseService.resume(ids);
		return new JsonResult().success("恢复任务成功");
	}

}